package com.maxwell.googleplay.base;

import android.app.Application;
import android.content.Context;
import android.os.Handler;
import android.os.Looper;

/**
 * @author yue
 * @创建时间 2016-3-29下午5:03:16
 * @描述 定义一个全局的盒子，里面放置的对象、属性、方法都是全局可以调用的
 * 
 */
public class BaseApplicaiton extends Application {

	private static Context mContext;
	private static Thread mMainThread;
	private static long mMainThreadId;
	private static Looper mMainLopper;
	private static Handler mHandler;

	@Override
	public void onCreate() {// 程序的入口
		// 初始化常用的属性

		// 上下文
		mContext = getApplicationContext();

		// 主线程
		mMainThread = Thread.currentThread();

		// 主线程id tid: thread id ; uid:user id ; pid: process id;
		mMainThreadId = android.os.Process.myTid();

		// 主线程looper
		mMainLopper = getMainLooper();

		//定义handler		
		mHandler = new Handler();
		
		super.onCreate();
	}

	public static Handler getHandler() {
		return mHandler;
	}

	public static Context getContext() {
		return mContext;
	}

	public static Thread getMainThread() {
		return mMainThread;
	}

	public static long getMainThreadId() {
		return mMainThreadId;
	}

	public static Looper getMainThreadLooper() {
		return mMainLopper;
	}
}
